// #include "Bsp_uart.h"
#ifndef _BSPUARTH_
#define _BSPUARTH_

#include "main.h"
#include "string.h"
#include "usart.h"
#include "top_scheme.h"
/* Private define-----------------------------------------------------------------------------*/
#define buff_size       2048                //2kb
#define buff_test       10240               //10kb
#define flash_rx        30720               //20kb
#define flash_size      40960               //40kB

#if RS485
#define EN485_L  HAL_GPIO_WritePin(EN_485_GPIO_Port, EN_485_Pin, GPIO_PIN_RESET);
#define EN485_H  HAL_GPIO_WritePin(EN_485_GPIO_Port, EN_485_Pin, GPIO_PIN_SET);
#endif /*RS232*/
/* Private typedef----------------------------------------------------------------------------*/

/* Private macro------------------------------------------------------------------------------*/

/* Private variables--------------------------------------------------------------------------*/
#if NB_IOT
extern uint8_t nbiot_rx_flag;
extern uint8_t nbiot_rx_buffer[buff_test];
extern uint32_t nbiot_rx_len;
#endif /*NB_IOT*/

#if G4_CAT1
extern uint8_t g4cat1_rx_flag;
extern uint8_t g4cat1_rx_buffer[buff_test];
extern uint32_t g4cat1_rx_len;
#endif

extern uint8_t time_count;                             //响应计数器

extern uint8_t flag_232,flag_485;                  //标记

extern uint8_t flash_buf[flash_size];
extern uint32_t flash_len;

extern uint8_t connent_rx_flag;
extern uint8_t connent_rx_buffer[buff_size];
extern uint32_t connent_rx_len;


extern uint8_t QS96_clean_flag;//计数器清0
extern uint8_t QS96_getdata_flag;//计数器数据获取
extern uint8_t QS96_clean_single_flag;//单个计数器清0
extern uint8_t QS96_getdata_single_flag;//单个计数器数据获取
extern uint8_t QS96_send_flag;//发送数据标记位


//Lora
#if LORA
extern uint8_t lora_rx_flag;
extern uint8_t lora_rx_buffer[buff_test];
extern uint32_t lora_rx_len;
#endif

#if RS485
extern uint8_t u485_rx_flag;                          //485接收到信息标志
extern uint8_t u485_rx_buffer[buff_test];
extern uint32_t u485_rx_len;
#endif /*RS485*/
/* Private function prototypes----------------------------------------------------------------*/

/* Private functions--------------------------------------------------------------------------*/
void Bsp_usart_enable();                                                                       //串口开启使能
void Send_Data(UART_HandleTypeDef *huart,uint8_t *buf,uint8_t len);                            //发送数据
void Send_answer(void);

void UsartReceive_IDLE(UART_HandleTypeDef *huart);
void usart3_rx_anaylse(void);

#endif

